package com.kawa.controller;

import com.kawa.entity.dto.LoginRequest;
import com.kawa.entity.vo.LoginResult;
import com.kawa.model.R;
import com.kawa.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class LoginController {

    @Autowired
    private LoginService loginService;



    @PostMapping("/login")
    public R<LoginResult> login(@RequestBody LoginRequest request) {

        // 调用登录服务
        LoginResult result = loginService.UserLogin(
                request.getUsername(),
                request.getPassword(),
                request.getCaptchaId(),
                request.getCaptchaCode()
        );
        return result != null ? R.ok(result) : R.fail();
    }
}
